﻿using MongoDB.Driver;
using Sustainalytics.ClientDW.Entities;
using Sustainalytics.ScreeningTool.Synchronization.Caches;
using Sustainalytics.ScreeningTool.Synchronization.Handlers;
using System;
using System.Collections.Generic;
using System.Linq;

namespace Sustainalytics.ScreeningTool.Synchronization.Processors
{
    public class GCOverallCompanySummaryExtendedProcessor : Processor<GCOverallCompanySummaryExtended>
    {
        private readonly IEnumerable<Guid> companyIds;

        public GCOverallCompanySummaryExtendedProcessor(
            IMongoCollection<GCOverallCompanySummaryExtended> collection,
            IHandler<GCOverallCompanySummaryExtended> handler,
            ResearchStatesCache researchStatesCache)
            : base(collection, handler)
        {
            companyIds = researchStatesCache.GetGccsCompanyIds();
        }

        protected override FilterDefinition<GCOverallCompanySummaryExtended> GetFilter()
        {
            return Builders<GCOverallCompanySummaryExtended>.Filter.Where(x => companyIds.Contains(x.Id));
        }
    }
}
